package com.bops.dal.product.dao.impl;

import java.util.List;

import com.bops.dal.product.dao.CloudDAO;
import com.bops.dal.product.dataobject.CloudDO;
import com.bops.dal.product.queryobject.CloudQuery;
import com.yue.commons.db.ibatis.YueBaseSqlMapClientDaoSupport;

public class CloudDAOImpl  extends YueBaseSqlMapClientDaoSupport implements CloudDAO{

	private static final String NAME_SPACE = "CLOUD_CLOUD.";
	
	public Integer insert(CloudDO cloudDO) {
		return (Integer) getSqlMapClientTemplate().insert(NAME_SPACE + "insert", cloudDO);
	}

	public boolean update(CloudDO cloudDO) {
		return getSqlMapClientTemplate().update(NAME_SPACE + "update", cloudDO) > 0;
	}

	public CloudDO getById(Integer id) {
		return (CloudDO) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "listById", id);
	}

    @SuppressWarnings("unchecked")
	public List<CloudDO> listCloud(CloudQuery query) {
    	if (query==null)
        {
            query = new CloudQuery();
            query.setPageSize(Integer.MAX_VALUE);
        }
		return getSqlMapClientTemplate().queryForPagination(NAME_SPACE + "count_cloud", NAME_SPACE + "list_cloud", query);
	}

	public boolean delete(Integer id) {
		return getSqlMapClientTemplate().delete(NAME_SPACE + "delete", id) > 0;
	}

	public int checkCloud(CloudDO editCloud) {
		return (Integer) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "checkName",  editCloud);
	}

}
